﻿#pragma once

struct AppArgs
{
  std::string windowTitle = "MyGLCraft";
  int32_t windowWidth = 800;
  int32_t windowHeight = 600;
};

struct GameArgs
{
  std::string saveName = "default";
};

struct ConfigArgs
{
  AppArgs appArgs;
  GameArgs gameArgs;

  bool LoadFromArgs(int argc, char **argv)
  {
    for (int i = 1; i < argc; i++)
    {
      std::string arg = argv[i];
      if (arg == "--title")
      {
        appArgs.windowTitle = argv[++i];
      }
      else if (arg == "--width")
      {
        appArgs.windowWidth = std::stoi(argv[++i]);
      }
      else if (arg == "--height")
      {
        appArgs.windowHeight = std::stoi(argv[++i]);
      }
      else if (arg == "--save")
      {
        gameArgs.saveName = argv[++i];
      }
      else
      {
        LOG_WARN("Unknown argument: {}", arg);
        return false;
      }
    }
    return true;
  }
};